<?php
namespace app\controller;

use app\BaseController;
use app\Request;
use think\facade\View;
use think\facade\Db;

class Index extends BaseController
{
    public function index(Request $request)
    {
        if($request->isAjax()){
            $post = $request->post();
            $post['recate_time'] = time();
            $state = Db::table('feedback')->save($post);
            if(!empty($state)){
                exit(json_encode(['code'=>1,'msg'=>'成功']));
            }
            exit(json_encode(['code'=>0,'msg'=>'失败']));
        }
        $type = Db::table('type')->order('id desc')->select();
        View::assign('type',$type);
        return View::fetch('index');
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }
}
